package com.example.commonmybatisplus.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.io.support.PropertySourceFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * * 使用 @PropertySource 加载配置
 * * 1.加载 yml
 * * 2. 加载 properties
 * * 3. 加载磁盘文件
 * * 4. 加载 xml文件（不推介）
 * <p>
 * yml加载的配置如果有下划线会自动被替换为空，因此需要使用双引号包裹
 *
 * @Author ifredomvip@gmail.com
 * @Date 2022/6/15 10:36
 * @Version 1.0.0
 * @Description
 **/
@Data
@Configuration
@PropertySource(value = "classpath:wechat-config.yml", factory = YamlSourceFactory.class)
@ConfigurationProperties(prefix = "wx")
public class LoadPropertySourceYmlConfig {

    private List<Config> configs;

    @Data
    public static class Config {
        private String appid;
        private String secret;
        private String token;
        private String aesKey;
    }


    private String appid;
    private String secret;
    private String token;
    private String aesKey;
}
